package org.cunamas.web.util;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class MessagesView  {
	
	private static ResourceBundle resources = ResourceBundle.getBundle("messages",Locale.getDefault());

	public static final String getI18nMessage(String idMessage){
		String message = null;
		try{
			message = resources.getString(idMessage);
			if (message == null) {
				return idMessage;
			}
		}
		catch(Exception e){
			System.out.println("error: " +e.getMessage());
		}
		return message;
	}
	

	public static final String getI18nMessageByParameters(String id,Object...ob){
			String message = null;
		
		try {
			MessageFormat form = new MessageFormat(getI18nMessage(id));
			message = form.format(ob);
		} catch (Exception e) {
			System.out.println("error: " +e.getMessage());
		}

		return message;
	}
}

